<?php
require_once("userView.php");
require_once(CORE_DIR.'userModel.php');
require_once(CORE_DIR.'taskpointModel.php');
require_once(CORE_DIR.'pointtypeModel.php');

class getuserprofilewithpointsAction extends Action{

	function __construct(){
		$this->view = new userView();
	}

	public function run($get, $post, $viewtype) {
		parent::run($get,$post,$viewtype);
		
		$uModel = new userModel();
		$tpModel = new taskpointModel();
		$ptModel = new pointtypeModel();
		
		if(isset($get["userid"])){
			$userid = $get["userid"];
			$user = $uModel->getUsersData($userid);
			$userPoints = $tpModel->getUserPoints($userid);
			$pointTypes = $ptModel->getPointTypes();
			
			$this->view->setProperty("userPoints", $userPoints);
			$this->view->setProperty("user", $user);
			$this->view->setProperty("pointTypes", $pointTypes);
			$this->view->showUserProfileWithPoints();
		}
		else {
			$this->view->showBadCmd();
		}
	}
}
?>